package centralizedme;

import java.util.LinkedList;

/**
 *
 * @author palexander
 */
public class RdfModel {
    // stores classes in model
    private LinkedList<RdfClass> classes;
    // opening RDF document string
    private String OPEN_RDF = "<rdf:RDF\n" +
            "      xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n" +
            "      xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\"\n" +
            "      xmlns:foaf=\"http://xmlns.com/foaf/0.1/\">\n";
    // closing RDF document string
    private String CLOSE_RDF = "</rdf:RDF>\n";

    /**
     * Default constructor.
     */
    public RdfModel() {
        classes = new LinkedList<RdfClass>();
    }

    /**
     * Add a class to the model.
     * @param rdfClass  Class to be added.
     */
    public void add(RdfClass rdfClass) {
        classes.add(rdfClass);
    }

    /**
     * Produces a string representation of the model.
     * @return  <code>String</code> representing the model in proper RDF syntax.
     */
    @Override
    public String toString() {
        StringBuffer s = new StringBuffer();

        s.append(OPEN_RDF);
        for (int i = 0; i < classes.size(); i++) {
            s.append(classes.get(i).toString());
        }
        s.append(CLOSE_RDF);

        return s.toString();
    }
}
